/**
 * [OElove] (C)2010-2099 OELOVE.COM Inc.biz
 * Email: service@phpcoo.com ,phpcoo@qq.com
 * This is NOT a freeware, use is subject to license terms
 * $ Last update 2017/05/10 by CL $
*/
$(function(){
	
	//登录会员 7.04.06
	$(document).on("click", "[f='but_index_login']", function(){
		$login_loginname = $("#login_loginname").val();
		$login_password = $("#login_password").val();
		if ($login_loginname.length == 0) {
			ToastShow("请输入登录帐号");
			return false;
		}
		if ($login_password.length == 0) {
			ToastShow("请输入登录密码");
			return false;
		}
		$("[f='but_index_login']").html("登录中...");
		$.ajax({
			type: "POST",
			url: _ROOT_PATH + "index.php?c=passport",
			cache: false,
			data: {a:"loginpost", loginname:$login_loginname, password:$login_password, from:"top", r:get_rndnum(8)},
			dataType: "json",
			success: function($data) {
				$json = eval($data);
				$response = $json.response;
				$result = $json.result;
				if ($response == "1") { //成功，返回页面
					window.location.reload();
				}
				else if ($response == "2") { //整合OEmarry
					window.top.location.href = $result;
				}
				else {
					if ($result.length > 0) {
						ToastShow($result);
					}
					else {
						ToastShow("登录失败，请检查帐号密码是否正确");
					}
					$("[f='but_index_login']").html("登&#12288;&#12288;录");
				}
			},
			error: function() {
				ToastShow("系统繁忙，请稍后再试");
			}
		});

	});

	//显示注册条款
	$(document).on("click", "[f='but_open_reg_clause']", function(){
		$("#reg_clause_box").show();
	});
	$(document).on("click", "[f='but_close_reg_clause']", function(){
		$("#reg_clause_box").hide();
	});
	
	//提交注册
	$(document).on("click", "[f='but_index_reg']", function(){
		$reg_loginname = $("#reg_loginname").val();
		$reg_password = $("#reg_password").val();
		if ($reg_loginname.length == 0) {
			ToastShow("请输入手机号码");
			return false;
		}
		if ($reg_password.length == 0) {
			ToastShow("请输入登录密码");
			return false;
		}
		$("#index_reg_form").submit();
	});

});